import { Module,NestModule,MiddlewareConsumer, RequestMethod } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { NewsModule } from './news/news.module'; //新闻模块
import { LoggerMiddleware } from './common/middleware/logger.middleware';


@Module({
  imports: [NewsModule],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule implements NestModule {
  configure(consumer: MiddlewareConsumer) {
    consumer
      .apply(LoggerMiddleware)
      .forRoutes('*')
      .apply(LoggerMiddleware)
      .exclude({path:'news',method: RequestMethod.GET})
      .forRoutes({path:'news',method: RequestMethod.GET});
  }
}
